home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-coverdisks-
/
126a
/
football
/
user
/
matchanalysis.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
12KB
|
397 lines
/* ***********************************************************************
MATCH ANALYSIS FOR FOOTBALL REXX SUITE
----------------------------------------
Copyright Mark Naughton 1997
Version Date History
--------------------------------------------------------------------------
1.0 050197 First release.
1.1 150997 Added code to handle automatic scheduling with dates.
As matches are played mid-week, it was better to get
all the games in a 7-day period than just reading the
Learn file where they are grouped together in the
number of teams divide by 2 (some games would be outside
this 7-day period). Amended displays.
1.2 250997 Amended displays of highest/lowest because when using
dates, these still gave the week numbers. Routine that
calculates the date for the listing is now a callable
procedure. Fixed bug where the program expected games
to be played every week and added games to weeks that
had no games played - the range wasn't incremented
enough.
151297 Tidied display. Added average number of goals per
game for highest/lowest.
**************************************************************************
Procedure
---------
1. Check files exist. Read Teams.df datafile and store league name.
2. If automatic scheduling, open Schedule definition file and store
whether it is run by WEEKS or DATES.
3. Open Learn file if WEEKS or non-auto sched and get statistics for
each match for each week. Close file.
4. Open '.sf' file if DATES and get statistics for each match for each
week. Increase the range from the start date as the file goes on, adding
7 days. Close file.
5. Get the highest and lowest scoring weeks.
6. Display data and exit.
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.df'
input2_file = '.sflearn'
input3_file = '.sf'
title = '*LEAGUE_NAME='
autosched = '*AUTOSCHD='
separator = '*'
games. = '???'
homew. = '???'
awayw. = '???'
draws. = '???'
losses. = '???'
goalss. = '???'
weeks = 0
weekend. = '???'
months = "January February March April May June July August September October November December"
not_played = '__ __'
parse var league_stuff league_file
league_file = "Data/" || league_file
if exists(league_file || input_file) = 0 then exit
if exists(league_file || input2_file) = 0 then exit
if exists(league_file || input3_file) = 0 then exit
autos = 0
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(title,line) > 0 then
league_title = delstr(line,1,13)
if pos(autosched,line) > 0 then do
autofile = delstr(line,1,10)
autos = 1
end
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"
say
say "Cannot read '"league_file || input_file"' for league name."
exit
end
type = 0
if autos = 1 then do
if open(datafile,"Data/"||autofile||".schd",'r') then do
line = readln(datafile)
if pos("*WEEKS",line) > 0 then
type = 10
if pos("*DATES",line) > 0 then do
type = 20
start_date = substr(line,8,8)
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"
say
say "Cannot read 'Data/"autofile".schd' to check what type of"
say "schedule it is."
exit
end
end
/* use this method if its WEEKS or non-auto sched. */
if type < 20 then do
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 then do
if pos(separator,sep) > 0 then do
weeks = weeks + 1
sep = ''
games.weeks = 0
homew.weeks = 0
awayw.weeks = 0
draws.weeks = 0
losses.weeks = 0
goalss.weeks = 0
goals_for = 0
goals_aga = 0
goals = 0
end
goals_for = strip(substr(line,32,2))
goals_aga = strip(substr(line,37,2))
if datatype(goals_for,'n') = 0 | datatype(goals_aga,'n') = 0 then
leave
games.weeks = games.weeks + 1
goalss.weeks = goalss.weeks + goals_for + goals_aga
if goals_for > goals_aga then do
homew.weeks = homew.weeks + 1
losses.weeks= losses.weeks + 1
end
if goals_for = goals_aga then do
draws.weeks = draws.weeks + 1
end
if goals_for < goals_aga then do
awayw.weeks = awayw.weeks + 1
losses.weeks= losses.weeks + 1
end
end
else
sep = line
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"
say
say "Cannot read '"league_file || input2_file"' datafile."
exit
end
end /* DATES and automatic scheduling */
if type = 20 then do
weeks = 1
mnth = substr(start_date,3,2)
ndate= substr(start_date,5,4)||mnth||substr(start_date,1,2)
range = date('b',ndate,'s')
range = range + 6
games.weeks = 0
weekend.weeks = range
homew.weeks = 0
awayw.weeks = 0
draws.weeks = 0
losses.weeks = 0
goalss.weeks = 0
goals_for = 0
goals_aga = 0
goals = 0
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) > 0 then do
if pos("*Date:",line) > 0 then do
year = word(line,5)
mnth = word(line,4)
day = word(line,3)
cv = 0
do i=1 to 12
if pos(mnth,word(months,i)) > 0 then do
cv = i
leave
end
end
sd = year||right(cv,2,0)||right(day,2,0)
search_date = date('b',sd,'s')
if search_date > range then do
range = range + 7
diff = 1
/* this hopes to skip weeks where no games are played. */
do while (diff > 0)
diff = search_date - range
if diff > 0 then
range = range + 7
end
weeks = weeks + 1
games.weeks = 0
weekend.weeks = range
homew.weeks = 0
awayw.weeks = 0
draws.weeks = 0
losses.weeks = 0
goalss.weeks = 0
goals_for = 0
goals_aga = 0
goals = 0
end
end
end
if pos(separator,line) = 0 & pos(not_played,line) = 0 then do
goals_for = strip(substr(line,32,2))
goals_aga = strip(substr(line,37,2))
if datatype(goals_for,'n') > 0 & datatype(goals_aga,'n') > 0 then do
games.weeks = games.weeks + 1
goalss.weeks = goalss.weeks + goals_for + goals_aga
if goals_for > goals_aga then do
homew.weeks = homew.weeks + 1
losses.weeks= losses.weeks + 1
end
if goals_for = goals_aga then do
draws.weeks = draws.weeks + 1
end
if goals_for < goals_aga then do
awayw.weeks = awayw.weeks + 1
losses.weeks= losses.weeks + 1
end
end
end
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"